<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Rightsandinterests extends Model
{
    protected $table = "c_rightsandinterests";

    public function getTypeAttribute($value)
    {
        return $this->getOptions()[$value];
    }


    public function getOptions()
    {
        return [
            0 => "铜牌工作室",
            1 => "银牌工作室",
            2 => "金牌工作室",
        ];
    }

    /**
     * @param $type
     * @return mixed
     * 获取协议
     */
    public function getInfo($type)
    {
        $res = self::where([['type', '=', $type['cate']], ['status', '=', 1],['user_type', '=', $type['user_type']]])->orderBy("id", "desc")->first();
        if ($res) {
            return $res->toArray();
        } else {
            return [];
        }
    }
}
